﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="YuZhiXX.aspx.cs" Inherits="Web.Pages.QuShui.DiXiaS.JiChuXX.YuZhiXX" Theme="Default"%>
<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="../../../../JS/AddEditCancel.js"></script>
    <script src="../../../../JS/jquery.js"></script>
    <script type="text/javascript">

        function display(op, id) {
            hdCollection.Set("ID", id);
            if (op == "add") {
                btnAdd.SetVisible(false);
                lblOperateTip.SetText("添加");
                txtBiaoHao.SetEnabled(true);
                txtBiaoHao.SetText("");
                listCover(true, "divList");
                $("#GridViewContentTable").show();
                txtBiaoHao.Focus();
            }
            else if (op == "edit") {
                btnAdd.SetVisible(false);
                lblOperateTip.SetText("修改");
                txtBiaoHao.SetEnabled(false);
                listCover(true, "divList");
                $("#GridViewContentTable").show();
                ASPxCallback1.PerformCallback("info");
                txtMingCheng.Focus();
            }
            else if (op == "init") {
                $("#GridViewContentTable").hide();
                btnAdd.SetVisible(true);
                listCover(false, "divList");
            }
        }

        function del(id) {
            hdCollection.Set("ID", id);
            if (confirm("确认删除吗？")) {
                ASPxCallback1.PerformCallback("del");
            }
            else {
                hdCollection.Set("ID", -1);
            }
        }

        function save() {
            if (txtBiaoHao.GetText() == "") {
                alert("编号不能为空！");
                txtBiaoHao.Focus();
                return;
            }
            if (txtMingCheng.GetText() == "") {
                alert("名称不能为空！");
                txtMingCheng.Focus();
                return;
            }
            ASPxCallback1.PerformCallback("save");
        }

        function display2(op, id) {
            hdCollection.Set("ID", id);
            if (op == "add2") {
                btnAdd2.SetVisible(false);
                lblOperateTip2.SetText("添加");
                txtBiaoHao2.SetEnabled(true);
                txtBiaoHao2.SetText("");
                listCover(true, "divList2");
                $("#GridViewContentTable2").show();
                txtBiaoHao2.Focus();
            }
            else if (op == "edit2") {
                btnAdd2.SetVisible(false);
                lblOperateTip2.SetText("修改");
                txtBiaoHao2.SetEnabled(false);
                listCover(true, "divList2");
                $("#GridViewContentTable2").show();
                ASPxCallback1.PerformCallback("info2");
                txtMingCheng2.Focus();
            }
            else if (op == "init2") {
                
                $("#GridViewContentTable2").hide();
                btnAdd2.SetVisible(true);
                listCover(false, "divList2");
            }
        }

        function del2(id) {
            hdCollection.Set("ID", id);
            if (confirm("确认删除吗？")) {
                ASPxCallback1.PerformCallback("del2");
            }
            else {
                hdCollection.Set("ID", -1);
            }
        }

        function save2() {
            if (txtBiaoHao2.GetText() == "") {
                alert("编号不能为空！");
                txtBiaoHao2.Focus();
                return;
            }
            if (txtMingCheng2.GetText() == "") {
                alert("名称不能为空！");
                txtMingCheng2.Focus();
                return;
            }
            ASPxCallback1.PerformCallback("save2");
        }

        function ASPxCallback1Complete(rs) {
            var arr = rs.split('|');
            var type = arr[0];
            var state = arr[1];
            var msg = arr[3].split('-');
            if (type == "info") {
                txtBiaoHao.SetText(arr[4]);
                txtMingCheng.SetText(arr[5]);
                txtMiaoShu.SetText(arr[6]);
            }
            else if (type == "del") {
                alert("删除成功！");
                gvList.PerformCallback();
            }
            else if (type == "save") {
                alert(msg[1]);
                
                txtBiaoHao.Focus();
                if (state!="False") {
                    display("init", -1);
                    gvList.PerformCallback();
                }
            }
            else if (type == "info2") {
                txtBiaoHao2.SetText(arr[4]);
                txtMingCheng2.SetText(arr[5]);
                txtMiaoShu2.SetText(arr[6]);
            }
            else if (type == "del2") {
                alert("删除成功！");
                gvList2.PerformCallback();
            }
            else if (type == "save2") {
                alert(msg[1]);
                txtBiaoHao2.Focus();
                if (state != "False") {
                    display2("init2", -1);
                    gvList2.PerformCallback();
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            预置信息
        </div>
        <div style="display: none;">
            <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
            <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
        </div>
        <asp:UpdatePanel runat="server" ID="updatePanel">
            <ContentTemplate>
                <dx:ASPxPageControl ID="ASPxPageControl1" runat="server" ActiveTabIndex="0" Width="100%">
                    <TabPages>
                        <dx:TabPage Text="井标记设置">
                            <ContentCollection>
                                <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                                    <div id="divList">
                                        <div align="center">
                                        </div>
                                        <div align="center">
                                            <dx:ASPxGridView ID="gvList" ClientInstanceName="gvList" runat="server" EnableCallBacks="false" AutoGenerateColumns="False" KeyFieldName="ID" Theme="Aqua1" Width="100%" OnCustomCallback="gvList_CustomCallback">
                                                <Columns>
                                                    <dx:GridViewDataTextColumn FieldName="S_YUZHIBH" Caption="编号" Width="25%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="S_YUZHIMC" Caption="名称" Width="30%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="S_BEIZHU" Caption="描述" Width="35%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn Width="5%">
                                                        <DataItemTemplate>
                                                            <a href="#" onclick="display('edit','<%#Eval("ID")%>')">修改</a>
                                                        </DataItemTemplate>
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn Width="5%">
                                                        <DataItemTemplate>
                                                            <a href="#" onclick="del('<%#Eval("ID")%>')">删除</a>
                                                        </DataItemTemplate>
                                                    </dx:GridViewDataTextColumn>
                                                </Columns>
                                                <SettingsBehavior AllowFocusedRow="True"  ColumnResizeMode="Control" />
                                                <Settings VerticalScrollableHeight="210" VerticalScrollBarMode="Auto" />
                                                <ClientSideEvents Init="function(s,e){AdjustSize(300,gvList);}" />
                                            </dx:ASPxGridView>
                                        </div>
                                    </div>
                                    <div style="height: 3px;"></div>
                                    <div style="text-align: right">
                                        <hr />
                                        <dx:ASPxButton ID="btnAdd" ClientInstanceName="btnAdd" runat="server" Text="添加" AutoPostBack="false" ClientSideEvents-Click="function(s,e){display('add',-1)}" UseSubmitBehavior="false">
                                        </dx:ASPxButton>
                                    </div>
                                    <div id="GridViewContentTable" style="display: none;">
                                        <div class="tabletitle1" align="center">
                                            <dx:ASPxLabel ID="lblOperateTip" runat="server" ClientInstanceName="lblOperateTip" Text="添加"></dx:ASPxLabel>
                                        </div>
                                        <table style="width: 65%; margin: auto;" class="TableLayoutFont">
                                            <tr>
                                                <td align="right" style="width: 20%;">编号：</td>

                                                <td style="width: 30%;">
                                                    <dx:ASPxTextBox ID="txtBiaoHao" ClientInstanceName="txtBiaoHao" runat="server" Width="100%" ClientEnabled="true" MaxLength="15">
                                                        <ClientSideEvents KeyPress="function(s,e){OnKeyNext(txtMingCheng);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="right">名称：
                                                </td>
                                                <td>
                                                    <dx:ASPxTextBox ID="txtMingCheng" ClientInstanceName="txtMingCheng" runat="server" Width="100%" MaxLength="30">
                                                        <ClientSideEvents KeyPress="function(s,e){OnKeyNext(txtMiaoShu);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                            <tr>

                                                <td align="right">描述：
                                                </td>
                                                <td>
                                                    <dx:ASPxTextBox ID="txtMiaoShu" ClientInstanceName="txtMiaoShu" runat="server" Width="100%" MaxLength="30">
                                                        <ClientSideEvents KeyPress="function(s,e){OnKeyNext(btnSave);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                        </table>
                                        <table id="GridViewButtonTable" runat="server" width="100%">
                                            <tr>
                                                <td style="text-align: right;">
                                                    <hr />
                                                    <dx:ASPxButton ID="btnSave" ClientInstanceName="btnSave" runat="server" Text="保存" AutoPostBack="false" UseSubmitBehavior="false" ClientSideEvents-Click="function(s,e){save();}">
                                                    </dx:ASPxButton>
                                                    <dx:ASPxButton ID="btnCancel" runat="server" Text="放弃" AutoPostBack="false" ClientSideEvents-Click="function(s,e){display('init',-1);}" UseSubmitBehavior="false">
                                                    </dx:ASPxButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </dx:ContentControl>
                            </ContentCollection>
                        </dx:TabPage>
                        <dx:TabPage Text="表标记设置">
                            <ContentCollection>
                                 <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                                    <div id="divList2">
                                        <div align="center">
                                        </div>
                                        <div align="center">
                                            <dx:ASPxGridView ID="gvList2" ClientInstanceName="gvList2" runat="server" EnableCallBacks="false" AutoGenerateColumns="False" KeyFieldName="ID" Theme="Aqua1" Width="100%" OnCustomCallback="gvList2_CustomCallback">
                                                <Columns>
                                                    <dx:GridViewDataTextColumn FieldName="S_BIAOBH" Caption="编号" Width="25%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="S_BIAOMINGC" Caption="名称" Width="30%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="S_MIAOSHU" Caption="描述" Width="35%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn Width="5%">
                                                        <DataItemTemplate>
                                                            <a href="#" onclick="display2('edit2','<%#Eval("ID")%>')">修改</a>
                                                        </DataItemTemplate>
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn Width="5%">
                                                        <DataItemTemplate>
                                                            <a href="#" onclick="del2('<%#Eval("ID")%>')">删除</a>
                                                        </DataItemTemplate>
                                                    </dx:GridViewDataTextColumn>
                                                </Columns>
                                                <SettingsBehavior AllowFocusedRow="True"  ColumnResizeMode="Control" />
                                                <Settings VerticalScrollableHeight="210" VerticalScrollBarMode="Auto" />
                                                <ClientSideEvents Init="function(s,e){AdjustSize(300,gvList2);}" />
                                            </dx:ASPxGridView>
                                            <%--<dx:ASPxLoadingPanel ID="ASPxLoadingPanel2" ClientInstanceName="loadpanel1" runat="server" ContainerElementID="gvList2" Modal="true" Theme="Metropolis" Text=""></dx:ASPxLoadingPanel>--%>
                                        </div>
                                    </div>
                                    <div style="height: 3px;"></div>
                                    <div style="text-align: right">
                                        <hr />
                                        <dx:ASPxButton ID="btnAdd2" ClientInstanceName="btnAdd2" runat="server" Text="添加" AutoPostBack="false" ClientSideEvents-Click="function(s,e){display2('add2',-1)}" UseSubmitBehavior="false">
                                        </dx:ASPxButton>
                                    </div>
                                    <div id="GridViewContentTable2" style="display: none;">
                                        <div class="tabletitle1" align="center">
                                            <dx:ASPxLabel ID="lblOperateTip2" runat="server" ClientInstanceName="lblOperateTip2" Text="添加"></dx:ASPxLabel>
                                        </div>
                                        <table style="width: 65%; margin: auto;" class="TableLayoutFont">
                                            <tr>
                                                <td align="right" style="width: 20%;">编号：</td>

                                                <td style="width: 30%;">
                                                    <dx:ASPxTextBox ID="txtBiaoHao2" ClientInstanceName="txtBiaoHao2" runat="server" Width="100%" ClientEnabled="true" MaxLength="15">
                                                        <ClientSideEvents KeyPress="function(s,e){OnKeyNext(txtMingCheng2);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="right">名称：
                                                </td>
                                                <td>
                                                    <dx:ASPxTextBox ID="txtMingCheng2" ClientInstanceName="txtMingCheng2" runat="server" Width="100%" MaxLength="30">
                                                        <ClientSideEvents KeyPress="function(s,e){OnKeyNext(txtMiaoShu2);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                            <tr>

                                                <td align="right">描述：
                                                </td>
                                                <td>
                                                    <dx:ASPxTextBox ID="txtMiaoShu2" ClientInstanceName="txtMiaoShu2" runat="server" Width="100%" MaxLength="30">
                                                        <ClientSideEvents KeyPress="function(s,e){OnKeyNext(btnSave2);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                        </table>
                                        <table id="Table1" runat="server" width="100%">
                                            <tr>
                                                <td style="text-align: right;">
                                                    <hr />
                                                    <dx:ASPxButton ID="btnSave2" ClientInstanceName="btnSave2" runat="server" Text="保存" AutoPostBack="false" UseSubmitBehavior="false" ClientSideEvents-Click="function(s,e){save2();}">
                                                    </dx:ASPxButton>
                                                    <dx:ASPxButton ID="btnCancel2" runat="server" Text="放弃" AutoPostBack="false" ClientSideEvents-Click="function(s,e){display2('init2',-1);}" UseSubmitBehavior="false">
                                                    </dx:ASPxButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </dx:ContentControl>
                            </ContentCollection>
                        </dx:TabPage>
                    </TabPages>
                </dx:ASPxPageControl>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>
